package org.richin.support.web.struts;

import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessages;
import org.richin.lang.util.StringUtils;
import org.richin.reflection.util.BeanUtils;
import org.richin.reflection.util.ReflectUtils;
import org.richin.support.biz.EntityManager;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;

@SuppressWarnings("unchecked")
public abstract class CRUDAction<T, M extends EntityManager> extends BaseCRUDAction<T, M>{

	public CRUDAction() {
		super();
	}
	/**
	 * 列出所有对象的Action函数.
	 */
	public ActionForward list(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response)throws Exception  {
		request.setAttribute(getEntityListName(), doListEntity());
		return mapping.findForward(LIST);
	}

	/**
	 * 获取业务对象列表的函数.
	 */
	protected List<T> doListEntity() {
		return getEntityManager().getAll();
	}

}